$(document).ready(function () {
	var oldIds = $("#ids").val();
	
	$("#drap-table").tableDnD({
		onDrop: function(table, row) {
			var rows = table.tBodies[0].rows;
            var ids = "";
            for (var i=0; i<rows.length; i++) {
            	if (ids != "") ids += ",";
            	ids += rows[i].id;
            }
            $("#ids").val(ids);
            if (oldIds != ids) {
            	$("#submit-order").removeAttr("disabled");
            }
        }
	});
	
	jQuery("#parentId").select2();
	
});